package com.ztesoft.book.api;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
import com.alibaba.nacos.api.annotation.NacosProperties;
import com.alibaba.nacos.spring.context.annotation.config.EnableNacosConfig;
import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.ComponentScan;
import springfox.documentation.oas.annotations.EnableOpenApi;


/**
 * @Description SpringBoot入口
 * @Author YangFan
 * @Date 2021-06-22 17:07
 */
@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)
@EnableOpenApi
@EnableCaching
@ComponentScan(basePackages = {
        "com.ztesoft.book.common",
        "com.ztesoft.book.core",
        "com.ztesoft.book.api"
})
@MapperScan("com.ztesoft.book.core.**.mapper")
@EnableNacosConfig(globalProperties = @NacosProperties(serverAddr = "${nacos.config.server-addr}"))
@NacosPropertySource(dataId = "${nacos.config.data-id}", groupId = "${nacos.config.group}", autoRefreshed = true, properties = @NacosProperties(namespace = "${nacos.config.namespace}"))
public class BookApiApplication extends SpringBootServletInitializer {

    static {
        System.setProperty("druid.mysql.usePingMethod", "false");
    }

    public static void main(String[] args) {
        SpringApplication.run(BookApiApplication.class, args);
    }


    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(BookApiApplication.class);
    }


}
